app.controller("reportInfoCtrl", ["$scope",'$filter',"ReportApi","sweetAlertUtil","ReportApi","$location",'$modal','$log',
    function($scope,$filter,ReportApi,sweetAlertUtil,ReportApi,$location,$modal,$log) {
        $scope.id = $location.search().id;

        init()
        function init(){
            ReportApi.getReportDetail($scope.id).then(function(data){
                if(data.code == 200){
                    $scope.result = data.result
                }
            }, function(){})
        }

        $scope.jsGetAge = function(h_birthday){
            var strBirthday = $filter('date')(h_birthday*1000, 'yyyy-MM-dd');
            var returnAge;
            var strBirthdayArr=strBirthday.split("-");
            var birthYear = strBirthdayArr[0];
            var birthMonth = strBirthdayArr[1];
            var birthDay = strBirthdayArr[2];

            d = new Date();
            var nowYear = d.getFullYear();
            var nowMonth = d.getMonth() + 1;
            var nowDay = d.getDate();

            if(nowYear == birthYear){
                returnAge = 0;//同年 则为0岁
            }else{
                var ageDiff = nowYear - birthYear ; //年之差
                if(ageDiff > 0){
                    if(nowMonth == birthMonth) {
                        var dayDiff = nowDay - birthDay;//日之差
                        if(dayDiff < 0){
                            returnAge = ageDiff - 1;
                        }else{
                            returnAge = ageDiff ;
                        }
                    }else{
                        var monthDiff = nowMonth - birthMonth;//月之差
                        if(monthDiff < 0){
                            returnAge = ageDiff - 1;
                        }else{
                            returnAge = ageDiff ;
                        }
                    }
                }else{
                    returnAge = -1;//返回-1 表示出生日期输入错误 晚于今天
                }
            }
            return returnAge;//返回周岁年龄
        }
        console.log($scope.jsGetAge('1988-10-02'))

        // ---------------------------start 打印设备 ----------------------------------
        $scope.banquetPrint = function(){
            var bdhtml=window.document.body.innerHTML;//获取当前页的html代码
            var startStr="<!--startprint-->";//设置打印开始区域
            var endStr="<!--endprint-->";//设置打印结束区域
            var printHtml=bdhtml.substring(bdhtml.indexOf(startStr)+startStr.length,bdhtml.indexOf(endStr));//从标记里获取需要打印的页面
            window.document.body.innerHTML=printHtml;//需要打印的页面
            window.document.body.innerHTML=bdhtml;//还原界面
        }
        // ---------------------------end 打印设备 ----------------------------------
    }
]);

//---------------- 点击图片显示模态框 ------------------
app.controller("imgtplCtrl", ['$scope', '$modalInstance', '$q', 'kw', 'sweetAlertUtil', function($scope, $modalInstance, $q, kw, sweetAlertUtil) {
    $scope.src = kw
    console.log($scope.src)
    //======关闭======
    $scope.cancel = function() {
        $modalInstance.dismiss('cancel');
    };
}])
